<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-lx-cascades"></i> 审核</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <el-form ref="form" :model="form" label-width="110px" label-position="left" >
                <el-label style="color: #00d1b2">当前待审核：</el-label>
                <el-button type="primary" icon="delete" class="mr10" @click="fresh">刷新</el-button>
            </el-form>
            <el-table :data="tableData1" border  v-loading="listLoading1" class="table"  stripe>
                <el-table-column prop="factname" width="120" label="计价器厂商名称" >
                </el-table-column>
                <el-table-column prop="jjqtype" label="计价器型号" >
                </el-table-column>
                <el-table-column prop="pricetype" label="价格类别" >
                </el-table-column>
                <el-table-column prop="filename" label="文件名" >
                </el-table-column>
                <el-table-column prop="pricefileno" label="物价文件编号" >
                </el-table-column>
                <el-table-column prop="stime" label="添加时间" >
                </el-table-column>
                <el-table-column prop="trafficcheck" label="交通局审核" >
                    <template slot-scope="scope">
                        <el-button  type="text"  size="small"  v-if="scope.row.trafficcheck==1">已审核</el-button>
                        <el-button  type="danger" size="small"  @click="handleTraffic(scope.$index, scope.row)"  :disabled="trafficline ===false" v-else="scope.row.trafficcheck==0">未审核</el-button>
                    </template>
                </el-table-column>
                <el-table-column prop="pricecheck" label="物价局审核" >
                    <template slot-scope="scope">
                        <el-button type="text" size="small"  v-if="scope.row.pricecheck==1">已审核</el-button>
                        <el-button  type="danger" size="small" @click="handlePrice(scope.$index, scope.row)" :disabled="priceline ===false" v-else="scope.row.pricecheck==0">未审核</el-button>
                    </template>
                </el-table-column>
                <el-table-column prop="metrologycheck" label="计量局审核" >
                    <template slot-scope="scope">
                        <el-button type="text" size="small"  v-if="scope.row.metrologycheck==1">已审核</el-button>
                        <el-button  type="danger" size="small" @click="handleMetrology(scope.$index, scope.row)" :disabled="metrologyline ===false" v-else="scope.row.metrologycheck==0">未审核</el-button>
                    </template>
                </el-table-column>
                <!--<el-table-column label="操作" width="160" align="center">-->
                    <!--<template slot-scope="scope">-->
                        <!--<el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>-->
                        <!--<el-button type="text" icon="el-icon-delete" class="red" @click="handleDelete(scope.$index, scope.row)">删除</el-button>-->
                    <!--</template>-->
                <!--</el-table-column>-->
                <el-table-column prop="memo" label="备注" >
                </el-table-column>
            </el-table>
            <el-col :span="24" class="toolbar pageBar">
                <el-pagination
                        @size-change="handleSizeChange1"
                        @current-change="handleCurrentChange1"
                        :current-page="currentPage1"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="pageSize1"
                        layout=" prev, pager, next, sizes, total"
                        :total="total1">
                </el-pagination>
            </el-col>
            <!--<div class="pagination">-->
            <!--<el-pagination background @current-change="handleCurrentChange" layout="prev, pager, next" :total="1000">-->
            <!--</el-pagination>-->
            <!--</div>-->

        <el-label style="color: #00d1b2">已审核：</el-label>
        <el-table :data="tableData2" border  v-loading="listLoading2" class="table"  stripe>
            <el-table-column prop="factname" width="120" label="计价器厂商名称" >
            </el-table-column>
            <el-table-column prop="jjqtype" label="计价器型号" >
            </el-table-column>
            <el-table-column prop="pricetype" label="价格类别" >
            </el-table-column>
            <el-table-column prop="filename" label="文件名" >
            </el-table-column>
            <el-table-column prop="pricefileno" label="物价文件编号" >
            </el-table-column>
            <el-table-column prop="stime" label="添加时间" >
            </el-table-column>
            <el-table-column prop="trafficcheck" label="交通局审核" >
                <template slot-scope="scope">
                    <el-button  type="text"  size="small"  v-if="scope.row.trafficcheck==1">已审核</el-button>
                    <el-button  type="danger" size="small"  @click="handleTraffic(scope.$index, scope.row)" v-else="scope.row.trafficcheck==0">未审核</el-button>
                </template>
            </el-table-column>
            <el-table-column prop="pricecheck" label="物价局审核" >
                <template slot-scope="scope">
                    <el-button type="text" size="small"  v-if="scope.row.pricecheck==1">已审核</el-button>
                    <el-button  type="danger" size="small" @click="handlePrice(scope.$index, scope.row)" v-else="scope.row.pricecheck==0">未审核</el-button>
                </template>
            </el-table-column>
            <el-table-column prop="metrologycheck" label="计量局审核" >
                <template slot-scope="scope">
                    <el-button type="text" size="small"  v-if="scope.row.metrologycheck==1">已审核</el-button>
                    <el-button  type="danger" size="small" @click="handleMetrology(scope.$index, scope.row)" v-else="scope.row.metrologycheck==0">未审核</el-button>
                </template>
            </el-table-column>
            <!--<el-table-column label="操作" width="160" align="center">-->
                <!--<template slot-scope="scope">-->
                    <!--<el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>-->
                    <!--<el-button type="text" icon="el-icon-delete" class="red" @click="handleDelete(scope.$index, scope.row)">删除</el-button>-->
                <!--</template>-->
            <!--</el-table-column>-->
            <el-table-column prop="memo" label="备注" >
            </el-table-column>
        </el-table>
        <el-col :span="24" class="toolbar pageBar">
            <el-pagination
                    @size-change="handleSizeChange2"
                    @current-change="handleCurrentChange2"
                    :current-page="currentPage2"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="pageSize2"
                    layout=" prev, pager, next, sizes, total"
                    :total="total2">
            </el-pagination>
        </el-col>
        <!--<div class="pagination">-->
        <!--<el-pagination background @current-change="handleCurrentChange" layout="prev, pager, next" :total="1000">-->
        <!--</el-pagination>-->
        <!--</div>-->
    </div>

        <!-- 交通部审核提示框 -->
        <el-dialog title="提示" :visible.sync="trafficCheckVisible" width="300px" center>
            <div class="del-dialog-cnt">审核通过？</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="trafficCheckVisible = false">取 消</el-button>
                <el-button type="primary" @click="trafficCheckCon">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 财务部审核提示框 -->
        <el-dialog title="提示" :visible.sync="priceCheckVisible" width="300px" center>
            <div class="del-dialog-cnt">审核通过？</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="priceCheckVisible = false">取 消</el-button>
                <el-button type="primary" @click="priceCheckCon">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 计量部审核提示框 -->
        <el-dialog title="提示" :visible.sync="metrologyCheckVisible" width="300px" center>
            <div class="del-dialog-cnt">审核通过？</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="metrologyCheckVisible = false">取 消</el-button>
                <el-button type="primary" @click="metrologyCheckCon">确 定</el-button>
            </span>
        </el-dialog>

    </div>
</template>



<script>
    export default {
        name: 'Check',
        data() {
            return {
                // url: 'http://localhost:9090',
                url:"/api",
                file: '',
                tableData1: [],
                tableData2: [],
                currentPage1: 1,
                currentPage2: 1,
                total1: 0,
                total2: 0,
                page1: 1,
                page2: 1,
                pageSize1: 10,
                pageSize2: 10,
                pageNum1:1,
                pageNum2:1,
                totalnum1:0,
                totalnum2:0,
                totalpage1:1,
                totalpage2:1,

                select_cate: '',
                select_word: '',
                del_list: [],
                is_search: false,
                listLoading1: false,
                listLoading2: false,

                metrologyline:false,
                priceline:false,
                trafficline:false,

                trafficCheckVisible:false,
                priceCheckVisible:false,
                metrologyCheckVisible:false,

                form3: {
                    factname: '',
                    jjqtype: '',
                    pricetype: '',
                    id:'',
                    factid: '',
                    jjqtypeid: '',
                    priceid: '',
                    trafficcheck:'',
                    traffictime:'',
                    pricecheck:'',
                    pricetime:'',
                    metrologycheck:'',
                    metrologytime:'',
                    pricefileno:'',
                    stime:'',
                    filename:'',
                    version:'',
                    fileinfo:'',
                    newbj:'',
                    fileid:''
                }
            }



        },
        created() {
            this.getData1();
            this.getData2()
        },

        methods: {
            fresh(){
                this.getData1();
                this.getData2()
            },
            //改变时
            handleSizeChange1(val) {
                this.pageSize1 = val;
                console.log(this.pageSize1);
                this.getData1();
            },
            //条目改变时
            handleCurrentChange1(val) {
                this.pageNum1 = val;
                console.log(this.pageNum1);
                this.getData1();
            },
            //改变时
            handleSizeChange2(val) {
                this.pageSize2 = val;
                console.log(this.pageSize2);
                this.getData1();
            },
            //条目改变时
            handleCurrentChange2(val) {
                this.pageNum2 = val;
                console.log(this.pageNum2);
                this.getData1();
            },
            //获取列表数据1
            getData1() {
                this.listLoading1 = true;
                this.$axios({
                    method: 'post',
                    url: this.url+"/paramfile/notcheck?pageNum="+this.pageNum1+"&pageSize="+this.pageSize1,
                }).then((res) => {
                    this.tableData1 = res.data.list;
                    this.total1 = res.data.totalnum;
                    this.page1 = res.data.totalpage;
                    this.listLoading1 = false;
                });
            },
            //获取列表数据2
            getData2() {
                this.listLoading2 = true;
                this.$axios({
                    method: 'post',
                    url: this.url+"/paramfile/checked?pageNum="+this.pageNum2+"&pageSize="+this.pageSize2,
                }).then((res) => {
                    this.tableData2 = res.data.list;
                    this.total2 = res.data.totalnum;
                    this.page2 = res.data.totalpage;
                    this.listLoading2 = false;
                });

                this.$axios({
                    method: 'post',
                    url: "/api/user/userinfopriv"
                }).then((res) => {
                    let istrafficline = false;
                    let ispriceline = false;
                    let ismetrologyline = false;

                    this.role = res.data;
                    console.log( this.role);
                    this.role.forEach(function (item, index) {
                        if(item.privilegeid == 5){
                            istrafficline = true;
                        }else if(item.privilegeid == 6){
                            ispriceline = true;
                        }else if(item.privilegeid == 7){
                            ismetrologyline = true;
                        }
                    });
                    if(istrafficline){
                        this.trafficline = istrafficline;
                    }
                    if(ispriceline){
                        this.priceline = ispriceline;
                    }
                    if(ismetrologyline){
                        this.metrologyline = ismetrologyline;
                    }
                })
            },


            filterTag(value, row) {
                return row.tag === value;
            },
            handleTraffic(index, row) {
                this.trafficCheckVisible = true;
                const item2 = this.tableData1[index];
                this.form3.id = item2.id;
            },
            handlePrice(index, row) {
                this.priceCheckVisible = true;
                const item2 = this.tableData1[index];
                this.form3.id = item2.id;
            },
            handleMetrology(index, row) {
                this.metrologyCheckVisible = true;
                const item2 = this.tableData1[index];
                this.form3.id = item2.id;
            },

            trafficCheckCon(){
                console.log(this.form3);
                this.$axios({
                    method: 'post',
                    url: this.url+"/paramfile/trafficsh",
                    data:this.form3
                }).then((res) => {
                    console.log(res);
                    if(res.data.message=="成功"){
                        this.$message.success('审核成功');
                        this.trafficCheckVisible = false;
                        this.getData1();
                        this.getData2();
                    }else {
                        this.$message.error(res.data.message);
                    }
                }).catch(function (error) {
                    console.log(error);
                });
            },
            priceCheckCon(){
                console.log(this.form3);
                this.$axios({
                    method: 'post',
                    url: this.url+"/paramfile/pricesh",
                    data:this.form3
                }).then((res) => {
                    console.log(res);
                    if(res.data.message=="成功"){
                        this.$message.success('审核成功');
                        this.priceCheckVisible = false;
                        this.getData1();
                        this.getData2();
                    }else {
                        this.$message.error(res.data.message);
                    }
                }).catch(function (error) {
                    console.log(error);
                });
            },
            metrologyCheckCon(){
                console.log(this.form3);
                this.$axios({
                    method: 'post',
                    url: this.url+"/paramfile/metrologysh",
                    data:this.form3
                }).then((res) => {
                    console.log(res);
                    if(res.data.message=="成功"){
                        this.$message.success('审核成功');
                        this.metrologyCheckVisible = false;
                        this.getData1();
                        this.getData2();
                    }else {
                        this.$message.error(res.data.message);
                    }
                }).catch(function (error) {
                    console.log(error);
                });
            }


        }
        //     // 获取uuid


    }

</script>

<style>
    .handle-box {
        margin-bottom: 20px;
    }

    .handle-select {
        width: 300px;
    }
    .handle-add-select {
        width: 200px;
    }
    .handle-input {
        width: 300px;
        display: inline-block;
    }
    .handle-add-input {
        width: 200px;
        display: inline-block;
    }
    .del-dialog-cnt{
        font-size: 16px;
        text-align: center
    }
    .table{
        margin-top: 10px;
        width: 100%;
        font-size: 14px;
    }
    .red{
        color: #ff0000;
    }
    .mr10{
        margin-left: 80%;
        width: 80px;
    }
    .customWidth{
        width:80%;
    }

</style>
